package com.mcxx.context;

import com.mcxx.constant.BusinessConstant;
import com.yinhai.ta404.core.context.TaUser;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;



@Data
public class HandleType {

    String handleType;


    String userLevel;


    String businessType;


    String areaCode;


    String recheckType;


    String operateStep;


    public HandleType(String handleType, String areaCode, String userLevel, String businessType, String recheckType, String operateStep) {
        this.handleType = handleType;
        this.userLevel = userLevel;
        this.businessType = businessType;
        this.areaCode = areaCode;
        this.recheckType = recheckType;
        this.operateStep = operateStep;
    }

    public HandleType(String handleType, String userLevel, String businessType, String recheckType, String operateStep) {
        this.handleType = handleType;
        this.areaCode = BusinessConstant.COMMON;
        this.userLevel = userLevel;
        this.businessType = businessType;
        this.recheckType = recheckType;
        this.operateStep = operateStep;
    }

    public HandleType(String handleType, TaUser user, String businessType, String recheckType, String operateStep) {
        this.handleType = handleType;
        this.userLevel = user.getAreaLevel();
        this.areaCode = user.getAreaCode();
        this.businessType = businessType;
        this.recheckType = recheckType;
        this.operateStep = operateStep;
    }

    public HandleType(String handleType, String businessType, String areaCode, String recheckType) {
        this.handleType = handleType;
        this.businessType = businessType;
        this.areaCode = areaCode;
        this.recheckType = recheckType;
        this.userLevel = BusinessConstant.COMMON;
        this.areaCode = BusinessConstant.COMMON;
    }

    public HandleType(String handleType, String recheckType, String operateStep) {
        this.handleType = handleType;
        this.userLevel = BusinessConstant.COMMON;
        this.areaCode = BusinessConstant.COMMON;
        this.businessType = BusinessConstant.COMMON;
        this.recheckType = recheckType;
        this.operateStep = operateStep;
    }

    public HandleType(String handleType, String operateStep) {
        this.handleType = handleType;
        this.userLevel = BusinessConstant.COMMON;
        this.areaCode = BusinessConstant.COMMON;
        this.businessType = BusinessConstant.COMMON;
        this.recheckType = BusinessConstant.COMMON;
        this.operateStep = operateStep;
    }

    public HandleType(String handleType) {
        this.handleType = handleType;
        this.userLevel = BusinessConstant.COMMON;
        this.areaCode = BusinessConstant.COMMON;
        this.businessType = BusinessConstant.COMMON;
        this.recheckType = BusinessConstant.COMMON;
        this.operateStep = BusinessConstant.COMMON;
    }

    public HandleType(){}

    public String toKey() {
        StringBuffer sb = new StringBuffer();
        sb.append(StringUtils.isEmpty(this.handleType)?BusinessConstant.COMMON:this.handleType).append("&");
        sb.append(StringUtils.isEmpty(this.userLevel)?BusinessConstant.COMMON:this.userLevel).append("&");
        sb.append(StringUtils.isEmpty(this.areaCode)?BusinessConstant.COMMON:this.areaCode).append("&");
        sb.append(StringUtils.isEmpty(this.businessType)?BusinessConstant.COMMON:this.businessType).append("&");
        sb.append(StringUtils.isEmpty(this.recheckType)?BusinessConstant.COMMON:this.recheckType).append("&");
        sb.append(StringUtils.isEmpty(this.operateStep)?BusinessConstant.COMMON:this.operateStep).append("&");
        return sb.toString();
    }

}
